package com.bjtu.ptsite.model;

import com.bjtu.ptsite.tracker.entity.TorrentEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *
 * @author Zehao Wang, Junjie Zhang, Yutao Wei
 *
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AnnounceRequest {
    private String passKey;
    private byte[] infoHashBytes;
    private String infoHashHex;
    private byte[] peerId;
    private String peer_id;
    private int port;
    private long uploaded;
    private long downloaded;
    private long left;
    private String ip;
    private String event;
    /**
     * 客户端希望指定多少个peer返回
     */
    private int numwant = 50;

    /**
     * passkey
     */
    private String passkey;

    /**
     * hash
     * 20字节SHA1哈希。请注意，该值将是一个b编码的字典
     */
    private byte[] infoHash;


    /**
     * 客户端ID（16进制）
     * 2d5452343033302d6264637a71111118386a3170
     */
    private String peerIdHex;



    /**
     * IPv6地址
     */
    private String ipv6;

    /**
     * IPv4地址
     */
    private String ipv4;


    /**
     * 密钥
     * <p>
     * 可选。一个不与任何其他客户端共享的附加标识。它旨在允许客户端在IP地址更改时证明其身份。
     */
    private String key;




    private Long redundant = 0L;

    private Integer compact;

    /**
     * "no_peer_id"：表示tracker可以在peers字典中省略peer id字段。如果启用了"compact"选项，则会忽略此选项。
     */
    private Integer no_peer_id;

    /**
     * 做种
     */
    private Boolean seeder;

    /**
     * 远程地址
     */
    private String remoteAddr;

    /**
     * 客户端信息
     */
    private String userAgent;

    /**
     * 想要的摘要信息
     */
    private String wantDigest;


    /**
     * 用户实体
     */
    private TorrentEntity torrent;


    public boolean isNoPeerId() {
        boolean noPeerId = Integer.valueOf(1).equals(getNo_peer_id());

        return noPeerId;
    }

    public interface EventType {
        // started, completed, stopped (或为空，这与未指定相同).
        //
        String STARTED = "started";
        String COMPLETED = "completed";
        String STOPPED = "stopped";
        String PAUSED = "paused";
        String EMPTY = "";
    }
}
